package com.battery.system.service.impl;

import com.battery.common.core.text.Convert;
import com.battery.system.domain.Address;
import com.battery.system.domain.Notice;
import com.battery.system.mapper.AddressMapper;
import com.battery.system.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 收货地址Service业务层处理
 *
 * @author battery
 * @date 2021-02-02
 */
@Service
public class AddressServiceImpl implements IAddressService
{
    @Autowired
    private AddressMapper addressMapper;

    /**
     * 查询收货地址
     *
     * @param id 收货地址ID
     * @return 收货地址
     */
    @Override
    public Address selectAddressById(String id)
    {
        return addressMapper.selectAddressById(id);
    }

    /**
     * 查询收货地址列表
     *
     * @param address 收货地址
     * @return 收货地址
     */
    @Override
    public List<Address> selectAddressList(Address address)
    {
        return addressMapper.selectAddressList(address);
    }

    /**
     * 新增收货地址
     *
     * @param address 收货地址
     * @return 结果
     */
    @Override
    public int insertAddress(Address address)
    {
        return addressMapper.insertAddress(address);
    }

    /**
     * 修改收货地址
     *
     * @param address 收货地址
     * @return 结果
     */
    @Override
    public int updateAddress(Address address)
    {
        return addressMapper.updateAddress(address);
    }

    /**
     * 删除收货地址对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteAddressByIds(String ids)
    {
        return addressMapper.deleteAddressByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除收货地址信息
     *
     * @param id 收货地址ID
     * @return 结果
     */
    @Override
    public int deleteAddressById(String id)
    {
        return addressMapper.deleteAddressById(id);
    }

    @Override
    public void updateAddressDefault(String id) {
        addressMapper.updateAddressDefault(id);
    }

    @Override
    public Notice selectGetNotice() {
        return addressMapper.selectGetNotice();
    }
}
